<%@ page language="java" pageEncoding="UTF-8" %>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <%@include file="../../common/include_list_head.jsp" %>
    <script type="text/javascript" src="${basePath }/component/datepicker/WdatePicker.js"></script>
    <script>
        /**
         *   同步所有接入系统
         */
        function doSyncAll() {
            doSy("");
        }

        /**
         * 同步勾选的接入系统
         */
        function doSync() {
            var ids = floatchickButton(0, "删除");
            if (ids != false) {
                doSy(ids);
            }
        }

        $(function(){
            if($("#warnL").length>0){
                setInterval("countDown()",300);
            }
        })

        function countDown(){
            $("#warnL").toggleClass("warn");
        }

        function doSy(appids) {
            showProgressBar();
            $.post("<%=request.getContextPath()%>/s/uc/sync/s", {appids: appids}, function (data) {
                top.Dialog.close();
                var html = "<div style='height: 400px;overflow-y: auto;font-family: weiruanyahei'>";
                $.each($.parseJSON(data), function (i, item) {
                    html += "<fieldset style='margin: 10px;'><legend style='font-size: 14px;color: blue;'>" + item.appname + "</legend><table style='width:100%'>";
                    $.each(item.listModelMsg, function (j, model) {
                        html += "<tr><td align='right' width='20%'>" + model.name + "：</td><td width='80%' align='left'>" + model.msg + "</td></tr>";
                    });
                    html += "</table></fieldset><div>";
                });
                top.Dialog.open({
                    InnerHtml: html,
                    Title: "同步结果",
                    Width: 500,
                    Height: 400,
                    ShowButtonRow: true,
                    ShowOkButton: false
                })
            });
        }
    </script>
    <style type="text/css">
        .warn {color: red}
    </style>
</head>
<body>
<div id="scrollContent">

    <s:if test="actionErrors.size()>0 || actionMessages.size()>0 || fieldErrors.size()>0">
        <div id="SystemErrorMessage">
            <s:actionerror/>
            <s:actionmessage/>
            <s:fielderror/>
        </div>
    </s:if>

    <s:form theme="simple" name="ysform">
        <s:hidden name="pager.formname" value="ysform"/>
        <s:hidden name="pager.currentPageno" id="yspager_currentPageno"/>
    </s:form>

    <s:if test="#type != null">
        <div style="line-height: 30px;margin: 5px 5px 5px 20px;color: blue;">
           同步业务系统的用户（<label id="warnL">其中livebos系统的用户表tuser表中必须有ls及state字段，其中ls为密码字段，state为状态字段</label>）、角色、菜单、用户角色关系及角色菜单关系到角色权限管理中心，同步删除业务系统已删除的信息，添加新增加的信息，菜单资源同步删除时关联删除已同步到门户分类下的资源。
            <%--<br>
            业务系统单独调用同步接口，url为：{门户地址}/AuC/s/sync/sasnl/****(时间的加密字符串，1分钟后失效，调用encrypt.jar里的com.apexedu.encrypt.Encrypt的getEncrypt()方法) <a href="/AuC/encrypt.jar" style="color: red;text-decoration: none;">点击下载encrypt.jar</a>--%>
        </div>
    </s:if>

    <div id="userRoleMenuButton">
        <s:if test="#type != null">
            <button onclick="doSyncAll()" type="button"><span class="icon_add" title="">全部同步</span></button>
            <button onclick="doSync()" type="button"><span class="icon_edit" title="">勾选同步</span></button>
        </s:if>
        <s:else>
            <button onclick="openEntity()"><span class="icon_add">新增</span></button>
            <button onclick="doModify()"><span class="icon_edit">修改</span></button>
            <button onclick="doRemove()"><span class="icon_delete">删除</span></button>
            <button onclick="doUniChangeState(1,this)"><span class="icon_ok" title="">启用</span></button>
            <button onclick="doUniChangeState(0,this)"><span class="icon_no" title="">禁用</span></button>
            <s:hidden name="changestate_parms" id="changestate_parms"
                      value="%{@com.apexedu.util.crypto.CipherUtil@encryptByAES('entityName:T_ACCESS_APP_REG;idName:appid')}"/>
        </s:else>
    </div>
    <div>
        <table class="tableStyle" style="width:100%;">
            <tr>
                <th width="3%"></th>
                <th nowrap="nowrap" width="8%">接入号</th>
                <th nowrap="nowrap" width="10%">业务系统名字</th>
                <%--<th nowrap="nowrap" width="10%">系统编号</th>--%>
                <th nowrap="nowrap" width="15%">业务系统地址</th>
                <th nowrap="nowrap" width="5%">系统类型</th>
                <th nowrap="nowrap" width="5%">是否启用</th>
                <th nowrap="nowrap" width="5%">受管类型</th>
                <th nowrap="nowrap" width="20%">备注</th>
            </tr>
            <s:iterator value="resultData">
                <tr>
                    <td align="center"><s:checkbox id="%{appid}" name="selectNode" fieldValue="%{appid}"/></td>
                    <td nowrap="nowrap"><s:property value="appid"/></td>
                    <td nowrap="nowrap">
                        <a href="javascript:openEntity('<s:property value="appid"/>')">
                            <font color="blue"><s:property value="appname"/></font></a>
                    </td>
                        <%--<td nowrap="nowrap"><s:property value="appcode"/></td>--%>
                    <td nowrap="nowrap"><s:property value="appurl"/></td>
                    <td nowrap="nowrap">${xtlx==1?"livebos":"apexssh"}</td>
                    <td nowrap="nowrap"><s:property value="stateText"/></td>
                    <td nowrap="nowrap">
                        <s:if test="syncDirection == 1">
                            <span title="客户端业务系统自行管理资源和权限，权限中心只能查看">自管</span>
                        </s:if>
                        <s:else>
                            <span title="允许权限中心管理资源和权限，客户端每次从服务端取资源和验证权限">托管</span>
                        </s:else>
                    </td>
                    <td nowrap="nowrap"><s:property value="memo"/></td>
                </tr>
            </s:iterator>
        </table>
    </div>
    <div style="height: 45px;">
        <div id="pagelist" style="display: none">
            <s:property value="pager.postToolBar" escape="false"/>
        </div>

        <div class="clear"></div>
    </div>
</div>
</body>
</html>
